import pygame
from plane_sprites import  *


pygame.init()

# print("游戏开始")
# hero_rect = pygame.Rect(100, 500, 120, 125)
#
# print("英雄的远点%d %d" %(hero_rect.x, hero_rect.y))
# print("英雄的尺寸%d %d" %(hero_rect.width, hero_rect.height))
# print("尺寸%d %d" % hero_rect.size)

screen = pygame.display.set_mode((480, 700))
bg = pygame.image.load("./images/background.png")
screen.blit(bg, (0, 0))
# pygame.display.update()

hero = pygame.image.load("./images/me1.png")
screen.blit(hero, (150, 400))
pygame.display.update()
clock = pygame.time.Clock()
hero_rect = pygame.Rect(150, 300, 102, 126)

enemy = GameSprite("./images/enemy1.png")
enemy1 = GameSprite("./images/enemy1.png", 2)
enemy_goup = pygame.sprite.Group(enemy, enemy1)

while True:
    clock.tick()
    eventlist =pygame.event.get()
    if len(eventlist) > 0:
        print(eventlist)
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            print("退出游戏")

            pygame.quit()

            exit()


    hero_rect.y -= 1
    if hero_rect.y == -126:
        hero_rect.y = 700
    screen.blit(bg, (0, 0))
    screen.blit(hero, hero_rect)

    enemy_goup.update()
    enemy_goup.draw(screen)
    pygame.display.update()

#pygame.quit()